using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;

namespace Atechnology.glassCAD.Shapes.CutViewer
{

    public class Utils
    {
        public static bool IsAngleInSector(double angle, int sectorNumber)
        {
            switch (sectorNumber)
            {
                case 0:
                    if (angle >= 0 && angle <= Math.PI / 2)
                        return true;
                    return false;
                case 1:
                    if (angle >= Math.PI / 2 && angle <= Math.PI)
                        return true;
                    return false;
                case 2:
                    if (angle >= Math.PI && angle <= 3 * Math.PI / 2)
                        return true;
                    return false;
                case 3:
                    if (angle >= 3 * Math.PI / 2 && angle <= 2 * Math.PI)
                        return true;
                    return false;                    
            }
            return false;
        }

        public static bool IsAngleInRange(double angle, double startAngle, double endAngle)
        {
            if (startAngle < endAngle)
            {
                if (angle > startAngle && angle < endAngle)
                    return true;

                return false;
            }
            else
            {
                if (angle < endAngle || angle - startAngle >= 0)
                    return true;

                return false;
            }
        }

        public static int GetAngleSector(double angle)
        {
            if (angle >= 0 && angle <= Math.PI / 2)
                return 0;
            else if (angle >= Math.PI / 2 && angle <= Math.PI)
                return 1;
            else if (angle >= Math.PI && angle <= 3 * Math.PI / 2)
                return 2;
            else if (angle >= 3 * Math.PI / 2 && angle <= 2 * Math.PI)
                return 3;
            return -1;            
        }

        public static string GetTra3Coordinates(float width, float height)
        {
            CultureInfo en = new CultureInfo("en-US");
            width = (float)Math.Round(width, 1);
            height = (float)Math.Round(height, 1);
            string strWidth = width.ToString(en).Replace(".", "");
            string strHeight = height.ToString(en).Replace(".", "");
            int widthLength = strWidth.Length;
            int heightLength = strHeight.Length;

            for (int i = 0; i < 5 - widthLength; i++)
                strWidth = strWidth.Insert(0, " ");

            for (int i = 0; i < 5 - heightLength; i++)
                strHeight = strHeight.Insert(0, " ");
                
            return strWidth + strHeight;
        }
    }
}
